package com.zhy.zhy_ormlite;

import android.database.SQLException;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

import com.zhy.zhy_ormlite.bean.Article;
import com.zhy.zhy_ormlite.bean.User;
import com.zhy.zhy_ormlite.db.ArticleDao;
import com.zhy.zhy_ormlite.db.UserDao;
import com.zhy.zhy_ormlite.utils.L;

import java.util.List;

import kocla.com.myapplication.R;
import kocla.com.myapplication.utils.DatabaseHelper;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        testAddArticle();
//        new ArticleDao(this).delete();
        new ArticleDao(this).queryAll();
    }


    public void testAddArticle() {
        User u = new User();
        u.setName("张鸿洋");
        new UserDao(this).add(u);
        Article article = new Article();
        article.setTitle("ORMLite的使用");
        article.setUser(u);
        new ArticleDao(this).add(article);
        /*testGetArticleById();*/
    }

 /*   public void testGetArticleById() {
        Article article = new ArticleDao(this).get(1);
        L.e(article.getUser() + " , " + article.getTitle());
        List<Article> lsit = new ArticleDao(this).listByUserId(1);
    }*/


}
